<template>
<div>
    <city-header></city-header>
    <city-search :cities="cities">
    </city-search>
    <city-list :cities="cities" :letter="letter" :touchChange="touchChange">
    </city-list>
    <city-alphabet :cities="cities" @Change="AlphabetHandleClick" @touchChange="touchAlphabetHandleClick">
    </city-alphabet>
</div>
</template>

<script>
import axios from 'axios'
import CityHeader from './compontents/Header.vue'
import CitySearch from './compontents/Search.vue'
import CityList from './compontents/List.vue'
import CityAlphabet from './compontents/Alphabet.vue'
export default {
    name: 'City',
    components: {
        CityHeader,
        CitySearch,
        CityList,
        CityAlphabet,
    },
    data() {
        return {
            cities: [],
            letter: '',
            touchChange: 0,
        }
    },
    methods: {
        getCityInfo() {
            axios.get('/static/mock/City.json').then(this.handleGetCity)
        },
        handleGetCity(res) {
            if (res.status && res.data) {
                const data = res.data;
                this.cities = data.city;

            }
        },
        AlphabetHandleClick(letter) {
            this.letter = letter;
        },
        touchAlphabetHandleClick(index) {
            this.touchChange = index
        }
    },
    mounted() {
        this.getCityInfo();

    }
}
</script>

<style scoped>

</style>
